home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / program / wx_lib10.zoo / wx_open.c < prev    next >
C/C++ Source or Header  |  1992-08-01  |  2KB  |  86 lines

  1. #include <wx_lib.h>
  2.  
  3. /*
  4.  * This procedure opens a window if the one the application owns isn't
  5.  * actually open.
  6.  */
  7. int        wx_open(ws)
  8. Window    *ws;
  9. {
  10.     /*
  11.      * If the window isn't marked active, or, if it is, if the window handle
  12.      * is negative (not a valid option), we're going to have to run the
  13.      * gamut.
  14.      */
  15.     if ((ws->open == FALSE) || (ws->hand <= 0)) {
  16.  
  17.         /*
  18.          * If the window isn't marked as created, or the window handle is
  19.          * something impossible to believe.
  20.          */
  21.         if ((ws->actv == FALSE) || (ws->hand <= 0)) {
  22.  
  23.             /*
  24.              * If there's no sensible info for the full size, open to the
  25.              * desktop dimensions.
  26.              */
  27.             if ((ws->full.g_w == 0) || (ws->full.g_h == 0)) {
  28.                 wind_get(0,WF_WORKXYWH,&ws->full.g_x,&ws->full.g_y,
  29.                         &ws->full.g_w,&ws->full.g_h);
  30.             }
  31.  
  32.             /*
  33.              * If there's an error opening the window, error out.
  34.              */
  35.             if ((ws->hand = wind_create(ws->type,ws->full.g_x,ws->full.g_y,
  36.                                        ws->full.g_w,ws->full.g_h)) < 0) {
  37.                 return FALSE;
  38.             }
  39.  
  40.             /*
  41.              * If we got this far, the window has been created, even if it isn't
  42.              * actually open.  Set the flag.
  43.              */
  44.             ws->actv = TRUE;
  45.         }
  46.  
  47.         /*
  48.          * If there are no sensible parameters for a first size, open to the 
  49.          * window's maximum size.
  50.          */
  51.         if ((ws->curr.g_w == 0) || (ws->curr.g_h == 0)) {
  52.             ws->curr.g_x = ws->full.g_x;
  53.             ws->curr.g_y = ws->full.g_y;
  54.             ws->curr.g_w = ws->full.g_w;
  55.             ws->curr.g_h = ws->full.g_h;
  56.         }
  57.  
  58.         /*
  59.          * Open the window.  If we get an error, delete the window
  60.          * that we've already created, and return an error condition.
  61.          */
  62.         if (wind_open(ws->hand,ws->curr.g_x,ws->curr.g_y,
  63.                         ws->curr.g_w,ws->curr.g_h) < 0) {
  64.             wind_delete(ws->hand);
  65.             return FALSE;
  66.         }
  67.  
  68.         /*
  69.          * Set up all our GRECTs.
  70.          */
  71.         wx_get(ws);
  72.  
  73.         /*
  74.          * Set the flag to indicate that the window has been opened
  75.          */
  76.         ws->open = TRUE;
  77.         ws->xpos = ws->minx;
  78.         ws->ypos = ws->miny;
  79.         wx_setclip(ws);
  80.     }
  81.     /*
  82.      * Indicate that we're doing alright.
  83.      */
  84.     return TRUE;
  85. }
  86.